# Contributor: Fernando Casas Schossow <casasfernando@outlook.com>
# Maintainer: Fernando Casas Schossow <casasfernando@outlook.com>
pkgname=ocaml-libvirt
pkgver=0.6.1.4
pkgrel=1
pkgdesc="OCaml binding for libvirt"
url="http://libvirt.org/ocaml/"
arch="aarch64 ppc64le x86_64" # restricted by ocaml
license="LGPL-2.1-or-later-WITH-linking-exception"
makedepends="ocaml ocaml-ocamldoc ocaml-findlib-dev libvirt-dev perl gawk"
subpackages="$pkgname-dev $pkgname-doc"
source="https://libvirt.org/sources/ocaml/$pkgname-$pkgver.tar.gz
	0001-Use-C99-standard-int64_t-instead-of-OCaml-defined-an.patch
	0001-Add-a-binding-for-virDomainCreateXML.patch
	0001-Suppress-errors-to-stderr-and-use-thread-local-virEr.patch
	0002-Don-t-bother-checking-return-from-virInitialize.patch
	0001-Remove-unused-not_supported-function.patch
	0001-Use-g-warn-error.patch
	0002-Update-dependencies.patch
	0003-Add-a-binding-for-virConnectGetAllDomainStats-RHBZ-1.patch
	0004-examples-Print-more-stats-in-the-get_all_domain_stat.patch
	0005-Change-binding-of-virConnectGetAllDomainStats-to-ret.patch"
builddir="$srcdir/$pkgname-$pkgver"
options="!check" # there is no test suite/unit tests

prepare() {
	default_prepare
	update_config_sub
}

build() {
	cd "$builddir"
	export OCAMLPARAM="safe-string=0,_"
	./configure \
		--host=$CHOST \
		--build=$CBUILD \
		--target=$CTARGET \
		--prefix=/usr
	make -C libvirt all
	make opt
}

check() {
	cd "$builddir"
}

package() {
	cd "$builddir"
	export DESTDIR="$pkgdir"
	export OCAMLFIND_DESTDIR="$DESTDIR/usr/lib/ocaml"
	mkdir -p "$OCAMLFIND_DESTDIR" "$OCAMLFIND_DESTDIR/stublibs"
	make install-opt
	install -D -m644 COPYING "$pkgdir/usr/share/licenses/$pkgname/COPYING"
	install -D -m644 COPYING.LIB "$pkgdir/usr/share/licenses/$pkgname/COPYING.LIB"
}

sha512sums="ed081a9b6f1388935e6a2ba0400e15881b3abb81a1079ab7fd88e72392ad29a0fd61550d3d7dc00682f283bc181d298af6519d19c3d15cf077988a3d6281d204  ocaml-libvirt-0.6.1.4.tar.gz
ca1c6503a121ae392c46a37e4b260041a12b692afb7f2da39396f490020fe11b2284ff6fe110eac6fabd01296adf2aa030f598e7349a0984323f7cd1c9fa67b0  0001-Use-C99-standard-int64_t-instead-of-OCaml-defined-an.patch
6404b398da1b41cd1fef41ce597a3d2b1dee44b636a403a9b730e9cec455c87b4bd4fa35eea869a12698623d4d9d667f5588032bac4938d4114f606fa499a1e0  0001-Add-a-binding-for-virDomainCreateXML.patch
e59b4127c2244ef6465090ccf6965f8ca4431e543bd4b8772527b0080af30da9834655fce195b61e860676f9f4747d2d22caf38dc0c2ecd102c4933f0a5da668  0001-Suppress-errors-to-stderr-and-use-thread-local-virEr.patch
7106aa55357b54409ca982ac60ff1243f4210a12fc3db7e6d355a5f317b947abe11d283ffc1c86193e93e6e30bd037f8883079a6dc83da33091adc449a31ddcd  0002-Don-t-bother-checking-return-from-virInitialize.patch
bbc97d03031ef187230607de4830a3b250b8283d52ec0a60a220d165b4af9fe0deeacf43b00c056b4e090d6cf8f6aae8eb26c72e38cfca95df9e85ce0b72fd40  0001-Remove-unused-not_supported-function.patch
830d93d7cd1dec1fcf3c0f762c61d056d62589972c26904b3711f9739745ab0125b117aff873abd3ff852c8ad03b3e779891d1420c3f21008915b4eb69d977bf  0001-Use-g-warn-error.patch
f1dd3862b6c3a5ee04a2d54a885bc0baa053de60cde4ceeb9b70c6de9a8b4bfcac77429bf64400973a2d867bab542ca728438b30f07ac756cd362db454d684c0  0002-Update-dependencies.patch
2b9ce951486ada9d700c4560e0d5c069d2b58c70d71ac70ee95900246a53ad6c5b2557fe82fc45b3f0fcdf7a966c2e1f442cc391758b0c9c6f7e755206e5e2c7  0003-Add-a-binding-for-virConnectGetAllDomainStats-RHBZ-1.patch
2a2f48cd744d5b697ffded415993aa21aea5b3335abb6dd1d2ae9efeb443ead362b9b6988764a0405e96f054d949b2927c0a7316dcb0e41e02b19379a40b8471  0004-examples-Print-more-stats-in-the-get_all_domain_stat.patch
abfcac22d22be5e2b552f2443244d62663d055d3eb9fd9ee9e82bcf21667d1a868cecc2bc5eac25097e9faca2ae20bd4ad6c0bb81eb072fa581ffbcd7ec3779b  0005-Change-binding-of-virConnectGetAllDomainStats-to-ret.patch"
